home *** CD-ROM | disk | FTP | other *** search
Wrap
RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) NNNNaaaammmmeeee RWTPtrDeque<T> - Rogue Wave library class SSSSyyyynnnnooooppppssssiiiissss #include <rw/tpdeque.h> RWTPtrDeque<T> deq; PPPPlllleeeeaaaasssseeee NNNNooootttteeee RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee requires the Standard C++ Library. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn This class maintains a pointer-based collection of values, implemented as a double-ended queue, or deque. Class TTTT is the type pointed to by the items in the collection. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee Isomorphic EEEExxxxaaaammmmpppplllleeee In this example, a double-ended queue of iiiinnnntttts is exercised. // tpdeque.cpp #include <rw/tpdeque.h> #include <iostream.h> /* * This program partitions integers into even and odd numbers */ int main(){ RWTPtrDeque<int> numbers; int n; PPPPaaaaggggeeee 1111 RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) cout << "Input an assortment of integers (EOF to end):" << endl; while (cin >> n) { if (n % 2 == 0) numbers.pushFront(new int(n)); else numbers.pushBack(new int(n)); } while (numbers.entries()) { cout << *numbers.first() << endl; delete numbers.popFront(); } return 0; } Program Input: 1 2 3 4 5 <eof> Program Output: 4 2 1 PPPPaaaaggggeeee 2222 RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) 3 RRRReeeellllaaaatttteeeedddd CCCCllllaaaasssssssseeeessss 5 Classes RRRRWWWWTTTTPPPPttttrrrrDDDDlllliiiisssstttt<<<<TTTT>>>>, RRRRWWWWTTTTPPPPttttrrrrSSSSlllliiiisssstttt<<<<TTTT>>>>,,,, and RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr<<<<TTTT>>>> also provide a Rogue Wave pointer-based interface to C++-standard sequence collections. Class ddddeeeeqqqquuuueeee<<<<TTTT****,,,, aaaallllllllooooccccaaaattttoooorrrr>>>> is the C++-standard collection that serves as the underlying implementation for this class. PPPPuuuubbbblllliiiicccc TTTTyyyyppppeeeeddddeeeeffffssss typedef deque<T*, allocator> container_type; typedef container_type::iterator iterator; typedef container_type::const_iterator const_iterator; typedef container_type::size_type size_type; typedef container_type::difference_type difference_type; typedef T* value_type; typedef T*& reference; typedef T* const& const_reference; PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee<<<<TTTT>>>>(); Constructs an empty, double-ended queue. RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee<<<<TTTT>>>>(const deque<T*, allocator>& deq); Constructs a double-ended queue by copying all elements of ddddeeeeqqqq. RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee<<<<TTTT>>>>(const RWTPtrDeque<T>& rwdeq); Copy constructor. RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee<<<<TTTT>>>>(size_type n, T* a); Constructs a double-ended queue with nnnn elements, each initialized to aaaa. RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee<<<<TTTT>>>>(T* const* first, T* const* last); Constructs a double-ended queue by copying elements from the array of TTTT****s pointed to by ffffiiiirrrrsssstttt, up to, but not including, the element pointed to by llllaaaasssstttt. PPPPaaaaggggeeee 3333 RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss RWTPtrDeque<T>& ooooppppeeeerrrraaaattttoooorrrr====(const RWTPtrDeque<T>& deq); Clears all elements of self and replaces them by copying all elements of ddddeeeeqqqq. RWTPtrDeque<T>& ooooppppeeeerrrraaaattttoooorrrr====(const deque<T*, allocator>& stddeq); Clears all elements of self and replaces them by copying all elements of ssssttttddddddddeeeeqqqq. bool ooooppppeeeerrrraaaattttoooorrrr<<<<(const RWTPtrDeque<T>& deq); Returns ttttrrrruuuueeee if self compares lexicographically less than ddddeeeeqqqq, otherwise returns ffffaaaallllsssseeee. Items in each collection are dereferenced before being compared. Assumes that type TTTT has well-defined less-than semantics. bool ooooppppeeeerrrraaaattttoooorrrr========(const RWTPtrDeque<T>& deq); Returns ttttrrrruuuueeee if self compares equal to ddddeeeeqqqq, otherwise returns ffffaaaallllsssseeee. Two collections are equal if both have the same number of entries, and iterating through both collections produces, in turn, individual elements that compare equal to each other. Elements are dereferenced before being compared. reference ooooppppeeeerrrraaaattttoooorrrr(((())))(size_type i); const_reference ooooppppeeeerrrraaaattttoooorrrr(((())))(size_type i) const; Returns a reference to the iiiith element of self. Index iiii should be between 0000 and one less then the number of entries, otherwise the results are undefined--nnnnoooo bbbboooouuuunnnnddddssss cccchhhheeeecccckkkkiiiinnnngggg iiiissss ppppeeeerrrrffffoooorrrrmmmmeeeedddd.... reference ooooppppeeeerrrraaaattttoooorrrr[[[[]]]](size_type i); const_reference ooooppppeeeerrrraaaattttoooorrrr[[[[]]]](size_type i) const; PPPPaaaaggggeeee 4444 RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) Returns a reference to the iiiith element of self. Index iiii must be between 0000 and one less then the number of entries in self, otherwise the function throws an exception of type RRRRWWWWBBBBoooouuuunnnnddddssssEEEErrrrrrrr. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss void aaaappppppppeeeennnndddd(T* a); Adds the item aaaa to the end of the collection. void aaaappppppppllllyyyy(void (*fn)(T*,void*), void* d); void aaaappppppppllllyyyy(void (*fn)(const T*,void*), void* d) const; void aaaappppppppllllyyyy(void (*fn)(T*&,void*), void* d); Applies the user-defined function pointed to by ffffnnnn to every item in the collection. This function must have one of the prototypes: void yourfun(T* a, void* d); void yourfun(const T* a, void* d); void yourfun(T*& a, void* d); for reference semantics. Client data may be passed through parameter dddd. reference aaaatttt(size_type i); const_reference aaaatttt(size_type i) const; Returns a reference to the iiiith element of self. Index iiii must be between 0000 and one less then the number of entries in self, otherwise the function throws an exception of type RRRRWWWWBBBBoooouuuunnnnddddssssEEEErrrrrrrr. iterator bbbbeeeeggggiiiinnnn(); const_iterator bbbbeeeeggggiiiinnnn() const; Returns an iterator positioned at the first element of self. PPPPaaaaggggeeee 5555 RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) void cccclllleeeeaaaarrrr(); Clears the collection by removing all items from self. void cccclllleeeeaaaarrrrAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy(); Removes all items from the collection aaaannnndddd uses ooooppppeeeerrrraaaattttoooorrrr ddddeeeelllleeeetttteeee to destroy the objects pointed to by those items. Do not use this method if multiple pointers to the same object are stored. bool ccccoooonnnnttttaaaaiiiinnnnssss (const T* a) const; If there exists an element tttt in self such that the expression ((((****tttt ======== ****aaaa)))) is true, returns ttttrrrruuuueeee. Otherwise, returns ffffaaaallllsssseeee. bool ccccoooonnnnttttaaaaiiiinnnnssss (bool (*fn)(const T*, void*), void *d) const; bool ccccoooonnnnttttaaaaiiiinnnnssss(bool (*fn)(T*,void*), void* d) const; Returns ttttrrrruuuueeee if there exists an element tttt in self such that the expression ((((((((****ffffnnnn))))((((tttt,,,,dddd)))))))) is ttttrrrruuuueeee, otherwise returns ffffaaaallllsssseeee. ffffnnnn points to a user-defined tester function which must have one of the prototypes: bool yourTester(T* a, void* d); bool yourTester(const T* a, void *d) Client data may be passed through parameter dddd. iterator eeeennnndddd(); const_iterator eeeennnndddd() const; Returns an iterator positioned "just past" the last element in self. size_type eeeennnnttttrrrriiiieeeessss() const; Returns the number of items in self. PPPPaaaaggggeeee 6666 RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) T* ffffiiiinnnndddd(const T* a) const; If there exists an element tttt in self such that the expression ((((****tttt ======== ****aaaa)))) is ttttrrrruuuueeee, returns tttt. Otherwise, returns rrrrwwwwnnnniiiillll. T* ffffiiiinnnndddd(bool (*fn)( T*,void*), void* d) const; T* ffffiiiinnnndddd(bool (*fn)(const T*,void*), void* d) const; If there exists an element tttt in self such that the expression ((((((((****ffffnnnn))))((((tttt,,,,dddd)))))))) is ttttrrrruuuueeee, returns tttt. Otherwise, returns rrrrwwwwnnnniiiillll. ffffnnnn points to a user-defined tester function which must have one of the prototypes: bool yourTester(T* a, void* d); bool yourTester(const T* a, void* d); Client data may be passed through parameter dddd. reference ffffiiiirrrrsssstttt(); const_reference ffffiiiirrrrsssstttt() const; Returns a reference to the first element of self. If the collection is empty, the function throws an exception of type RRRRWWWWBBBBoooouuuunnnnddddssssEEEErrrrrrrr. size_type iiiinnnnddddeeeexxxx(const T* a) const; Returns the position of the first item tttt in self such that ((((****tttt ======== ****aaaa)))), or returns the static member nnnnppppoooossss if no such item exists. size_type iiiinnnnddddeeeexxxx(bool (*fn)(T*,void*), void* d) const; size_type iiiinnnnddddeeeexxxx(bool (*fn)(const T*,void*), void* d) const; Returns the position of the first item tttt in self such that((((((((****ffffnnnn))))((((tttt,,,,dddd)))))))) is ttttrrrruuuueeee,,,, or returns the static member nnnnppppoooossss if no such item exists. ffffnnnn points to a user-defined tester function which must have one of the prototypes: PPPPaaaaggggeeee 7777 RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) bool yourTester(T* a, void* d); bool yourTester(const T* a, void* d); Client data may be passed through parameter dddd. bool iiiinnnnsssseeeerrrrtttt(T* a); Adds the item aaaa to the end of the collection. Returns ttttrrrruuuueeee. void iiiinnnnsssseeeerrrrttttAAAAtttt(size_type i, T* a); Inserts the item aaaa in front of the item at position iiii in self. This position must be between zero and the number of entries in the collection, otherwise the function throws an exception of type RRRRWWWWBBBBoooouuuunnnnddddssssEEEErrrrrrrr. bool iiiissssEEEEmmmmppppttttyyyy() const; Returns ttttrrrruuuueeee if there are no items in the collection, ffffaaaallllsssseeee otherwise. T*& llllaaaasssstttt(); T* const & llllaaaasssstttt() const; Returns a reference to the last element of self. reference mmmmaaaaxxxxEEEElllleeeemmmmeeeennnntttt(); const_reference mmmmaaaaxxxxEEEElllleeeemmmmeeeennnntttt() const; reference mmmmiiiinnnnEEEElllleeeemmmmeeeennnntttt(); const_reference mmmmiiiinnnnEEEElllleeeemmmmeeeennnntttt() const; Returns a reference to the maximum or minimum element in self. size_type ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(const T* a) const; PPPPaaaaggggeeee 8888 RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) Returns the number of elements tttt in self such that the expression ((((****tttt ======== ****aaaa)))) is ttttrrrruuuueeee. size_type ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(bool (*fn)(T*,void*), void* d) const; size_type ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(bool (*fn)(const T*,void*), void* d) const; Returns the number of elements tttt in self such that the expression((((((((****ffffnnnn))))((((tttt,,,,dddd)))))))) is ttttrrrruuuueeee. ffffnnnn points to a user-defined tester function which must have one of the prototypes: bool yourTester(T* a, void* d); bool yourTester(const T* a, void* d); Client data may be passed through parameter dddd. T* ppppooooppppBBBBaaaacccckkkk(); Removes and returns the last item in the collection. T* ppppooooppppFFFFrrrroooonnnntttt(); Removes and returns the first item in the collection. void pppprrrreeeeppppeeeennnndddd(T* a); Adds the item aaaa to the beginning of the collection. void ppppuuuusssshhhhBBBBaaaacccckkkk(T* a); Adds the item aaaa to the end of the collection. void ppppuuuusssshhhhFFFFrrrroooonnnntttt(T* a); Adds the item aaaa to the beginning of the collection. PPPPaaaaggggeeee 9999 RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) T* rrrreeeemmmmoooovvvveeee(const T* a); Removes and returns the first element tttt in self such that the expression ((((****tttt ======== ****aaaa)))) is ttttrrrruuuueeee. Returns rrrrwwwwnnnniiiillll if there is no such element. T* rrrreeeemmmmoooovvvveeee(bool (*fn)(T*, void*), void* d); T* rrrreeeemmmmoooovvvveeee(bool (*fn)(const T*,void*), void* d); Removes and returns the first element tttt in self such that the expression ((((((((****ffffnnnn))))((((tttt,,,,dddd)))))))) is ttttrrrruuuueeee. Returns rrrrwwwwnnnniiiillll if there is no such element. ffffnnnn points to a user-defined tester function which must have one of the prototypes: bool yourTester(T* a, void* d); bool yourTester(const T* a, void* d); Client data may be passed through parameter dddd. size_type const T* rrrreeeemmmmoooovvvveeeeAAAAllllllll(const_reference a); Removes all elements tttt in self such that the expression ((((****tttt ======== ****aaaa)))) is ttttrrrruuuueeee. Returns the number of items removed. size_type rrrreeeemmmmoooovvvveeeeAAAAllllllll(bool (*fn)(T*,void*), void* d); size_type rrrreeeemmmmoooovvvveeeeAAAAllllllll(bool (*fn)(const T*,void*), void* d); Removes all elements tttt in self such that the expression ((((((((****ffffnnnn))))((((tttt,,,,dddd))))))))is ttttrrrruuuueeee. Returns the number of items removed. ffffnnnn points to a user-defined tester function which must have one of the prototypes: bool yourTester(T* a, void* d); bool yourTester(const T* a, void* d); Client data may be passed through parameter dddd. PPPPaaaaggggeeee 11110000 RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) T* rrrreeeemmmmoooovvvveeeeAAAAtttt(size_type i); Removes and returns the item at position iiii in self. This position must be between zero and one less then the number of entries in the collection, otherwise the function throws an exception of type RRRRWWWWBBBBoooouuuunnnnddddssssEEEErrrrrrrr. T* rrrreeeemmmmoooovvvveeeeFFFFiiiirrrrsssstttt(); Removes and returns the first item in the collection. T* rrrreeeemmmmoooovvvveeeeLLLLaaaasssstttt(); Removes and returns the first item in the collection. size_type rrrreeeeppppllllaaaacccceeeeAAAAllllllll(const T* oldVal, T* newVal); Replaces with nnnneeeewwwwVVVVaaaallll all elements tttt in self such that the expression ((((****tttt ======== ****oooollllddddVVVVaaaallll)))) is ttttrrrruuuueeee. Returns the number of items replaced. size_type rrrreeeeppppllllaaaacccceeeeAAAAllllllll(bool (*fn)(T*, void*), void* x, T* newVal); size_type rrrreeeeppppllllaaaacccceeeeAAAAllllllll(bool (*fn)(const T*, void*), void* x, const T* newVal); Replaces with nnnneeeewwwwVVVVaaaallll all elements tttt in self such that the expression ((((((((****ffffnnnn))))((((tttt,,,,dddd))))))))is ttttrrrruuuueeee. Returns the number of items replaced. ffffnnnn points to a user-defined tester function which must have one of the prototypes: bool yourTester(T* a, void* d); bool yourTester(const T* a, void* d); Client data may be passed through parameter dddd. void ssssoooorrrrtttt(); Sorts the collection using the less-than operator to compare elements. PPPPaaaaggggeeee 11111111 RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrDDDDeeeeqqqquuuueeee((((3333CCCC++++++++)))) Elements are dereferenced before being compared. deque<T*, allocator>& ssssttttdddd(); const deque<T*, allocator>& ssssttttdddd() const; Returns a reference to the underlying C++-standard collection that serves as the implementation for self. SSSSttttaaaattttiiiicccc PPPPuuuubbbblllliiiicccc DDDDaaaattttaaaa MMMMeeeemmmmbbbbeeeerrrr size_type nnnnppppoooossss; This is the value returned by member functions such as iiiinnnnddddeeeexxxx to indicate a non-position. The value is equal to ~~~~((((ssssiiiizzzzeeee____ttttyyyyppppeeee))))0000. RRRReeeellllaaaatttteeeedddd GGGGlllloooobbbbaaaallll OOOOppppeeeerrrraaaattttoooorrrrssss RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(RWvostream& strm, const RWTPtrDeque<T>& coll); RWFile& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(RWFile& strm, const RWTPtrDeque<T>& coll); Saves the collection ccccoooollllllll onto the output stream ssssttttrrrrmmmm, or a reference to it if it has already been saved. RWvistream& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWvistream& strm, RWTPtrDeque<T>& coll); RWFile& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWFile& strm, RWTPtrDeque<T>& coll); Restores the contents of the collection ccccoooollllllll from the input stream ssssttttrrrrmmmm. RWvistream& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWvistream& strm, RWTPtrDeque<T>*& p); RWFile& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWFile& strm, RWTPtrDeque<T>*& p); Looks at the next object on the input stream ssssttttrrrrmmmm and either creates a new collection off the heap and sets pppp to point to it, or sets pppp to point to a previously read instance. If a collection is created off the heap, then you are responsible for deleting it. PPPPaaaaggggeeee 11112222